from django.core.mail import send_mail
from django.template.loader import render_to_string
from django.contrib.sites.models import Site
from django.conf import settings

import threading

class WelcomeEmailThread(threading.Thread):
    def __init__(self,subject,message,email):
        self.subject = subject
        self.message = message
        self.email = email
        if hasattr(settings, 'EMAIL_SENDER_NAME'):
            self.sender = '%s <%s>' % (settings.EMAIL_SENDER_NAME, settings.EMAIL_HOST_USER)
        else:
            self.sender = settings.EMAIL_HOST_USER
        threading.Thread.__init__(self)
        
    def run(self):
        send_mail(self.subject, self.message, self.sender, [self.email], fail_silently=True)